package jp.sinya.verify;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;

public class VerifyCodeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        VerifyCodeUtils vc = new VerifyCodeUtils();
        BufferedImage img = vc.getImage();
        //提取验证码图片上的文字 博保存到session中
        req.getSession().setAttribute("verify_code", vc.getText());

        //保存图片到resp输出流上
        VerifyCodeUtils.output(img, resp.getOutputStream());
    }
}
